﻿@model List<WqUser>

@{
    ViewData["Title"] = "用户列表";
    ViewData["container-css"] = "col-md-12";
    var list = Model;
    var enable = (bool)ViewData["enable"];
    var page = ViewData["page"] as PageModel;
    var enableCount = (int)ViewData["enable-count"];
    var disableCount = (int)ViewData["disable-count"];
}

@section search{
    @Html.Partial("_ManageSearch", new KeyValuePair<string, string>("输入标题,关键字搜索", ViewData["search"].ToString()))
}

<div class="row">
    <div class="col-md-12">
        <ul id="tab-div" class="nav nav-tabs" role="tablist">
            <li class="@(enable?"active":"")"><a href="@Url.Action("List")" role="tab">正常用户 <i class="fa">@enableCount</i> </a></li>
            <li class="@(enable?"":"active")"><a href="@Url.Action("DisableList")" role="tab">禁用用户<i class="fa">@disableCount</i> </a></li>
        </ul>

        <div class="margin-top-10"></div>

        <div id="div-tab-list" class="tab-content">
            <div id="div-show" class="tab-pane active">
                <table class="@ViewHelper.Standard_table_css">
                    <thead>
                        <tr>
                            <th data-column-name="@nameof(WqUser.NickName)">昵称</th>
                            <th data-column-name="@nameof(WqUser.UserName)">用户名</th>
                            <th data-column-name="@nameof(WqUser.LoginType)">账户类型</th>
                            <th data-column-name="@nameof(WqUser.OpenIdQQ)">关联账户ID</th>
                            <th data-column-name="@nameof(WqUser.UserAuth)">角色/权限</th>
                            <th data-column-name="@nameof(WqUser.CreateTime)">创建时间</th>
                            <th data-column-name="@nameof(WqUser.LoginTime)">登录时间</th>
                            <th data-column-name="@nameof(WqUser.LastUpdate)">更新时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        @{
                            if (list.Count > 0)
                            {
                                foreach (var item in list)
                                {
                                    var href = Url.Action("Detail", new { id = item.Id });
                                    <tr data-id="@item.Id">
                                        <td><a href="@href">@item.NickName</a></td>
                                        <td title="@item.Id">@item.UserName</td>
                                        <td>
                                            @{
                                                foreach (SupportOpenIdTypes support in Enum.GetValues(typeof(SupportOpenIdTypes)))
                                                {
                                                    if (item.LoginType.HasFlag(support))
                                                    {
                                                        <span>@support.ToString()</span>
                                                    }
                                                }
                                            }
                                        </td>
                                        <td>@($"{item.OpenIdQQ}{item.OpenIdBaidu}{item.OpenIdAli}")</td>
                                        <td>
                                            @{
                                                if (item.IsAdmin)
                                                {
                                                    <span style="color:red;">Admin</span>
                                                }
                                                else
                                                {
                                                    <span style="color:green;">N/A</span>
                                                }
                                            }
                                            @{
                                                foreach (WqUserAuth auth in Enum.GetValues(typeof(WqUserAuth)))
                                                {
                                                    if (item.UserAuth.HasFlag(auth))
                                                    {
                                                        <span>@auth.ToString()</span>
                                                    }
                                                }
                                            }
                                        </td>
                                        <td>@item.CreateTime.ToLocalDateTimeString()</td>
                                        <td>@item.LoginTime.ToLocalDateTimeString()</td>
                                        <td>@item.LastUpdate.ToLocalDateTimeString()</td>
                                    </tr>
                                }
                            }
                            else
                            {
                                @Html.Raw(ViewHelper.Standard_no_record_tr)
                            }
                        }
                    </tbody>
                </table>
                @Html.Partial("Pagination", page)
            </div>
        </div>
    </div>
</div>